<template>
<d2-container>
    <template slot="header">视频上传</template>
      <div class="t-upload__file-flow-demo">
    <div>是否重复文件上传：<t-switch v-model="allowUploadDuplicateFile"></t-switch></div>
    <t-upload
      v-model="file"
      action="/api/video/upload"
      accept='video/*'
      placeholder="支持批量上传文件，文件格式不限，最多只能上传 10 份文件"
      theme="file-flow"
      multiple
      :allowUploadDuplicateFile="allowUploadDuplicateFile"
      :auto-upload="false"
      :max="10"
       @success="handleUploadSuccess"
       @fail='handleUploadFail'
       :headers='headers'
    ></t-upload>
  </div>
  </d2-container>

</template>

<script>
export default {
  name: 'TUploadFileFlow',

  data() {
    return {
      file: [],
      // token: this.$store.state.d2admin.user.token,
      headers: {
Authorization: `Bearer${this.$store.state.d2admin.user.token}`
      },
      allowUploadDuplicateFile: false
    }
  },
  methods: {
     handleUploadSuccess(e) {
      console.log('batch upload', e)
      this.$notify.success({ title: '上传成功', icon: true, content: `${e.file.name}已上传` })
      this.file = []
    },
    handleUploadFail(e) {
 console.log('batch fail', e)
 this.$notify.warning({ title: '上传失败', icon: true, content: `${e.file.name}遇到不可知错误` })
    }
  }
}
</script>
